#pragma once
#include "Socket.h"
#include "EventLoop.h"
#include <string>
#include "Channel.h"
#include "InetAddress.h"
#include "Epoll.h"
#include "Acceptor.h"
#include<map>
#include"Connection.h"
// TcpServer网路服务类
class TcpServer
{
public:
    TcpServer(std::string &ip, uint16_t &port);
    ~TcpServer();

    void start();
    void newConnection(Socket *clientsock);

    void closeconnection(Connection *conn);
    void errorconnection(Connection *conn);
    void onmessage(Connection *conn, std::string message);

    void sendcomplete(Connection* conn);

    void epolltimeout(EventLoop *loop);
   
   

private:
    EventLoop loop_;
    Acceptor *acceptor_;
    std::map<int,Connection*> conns_;
};
